<?php
require_once 'const/RequestConst.php';
?>
<html>
    <head>
        <title>Admin</title>
        <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
        <link href="/css/admin/css.css" rel="stylesheet" type="text/css" />
        <script language="JavaScript" src="/jscript/admin/js.js"></script>
        <script language="JavaScript" src="/jscript/comm/simpleajax.js"></script>
        <script language="javascript">
            function checkData() {
                if(document.form1.name.value == '') {
                    alert('类别名称不能为空！');
                    document.form1.name.focus;
                    return false;
                }
            }
        </script>
    </head>
    <body style="overflow-x:hidden;">
        <form method="post" action="<?php echo "/admin/add-type?id=" . $this->id ?>" name="form1" id="form1" target="adminMain" onSubmit="return checkData();">
            <div id="divMainBodyTop">
                <div class="fLeft"><img src="/images/default/admin/edit.gif" width="15" height="13"></div>
                <div>商品类别设置</div>
            </div>
            <div id="BodyContent">
                <div id="divClasses" class="fLeft">
                    <?php foreach ($this->types as $type): ?>
                        <div>
                            <div class="fLeft fb" id="classes">
                                <a><?php echo $type[C_NAME] ?></a>
                            </div>
                            <div id="sortid" class="fLeft">
                                <a title="修改此类别" href="<?php echo "/admin/type?cmd=modify&id=" . $type['ID'] ?>" target="adminMain">修改</a>
                                <a onClick="return delYesOrNo();" title="删除" href="<?php echo "/admin/type?cmd=delete&id=" . $type['ID'] ?>" target="adminMain">删除</a>
                            </div>
                        </div>
                        <div class="cls"></div>
                    <?php endforeach; ?>

                        <div id="classes" class="fLeft">&nbsp;</div><div id="sortid" class="fLeft">&nbsp;</div>

                        <div class="cls"></div>
                    </div>
                    <div class="fLeft" style="width:50%;">
                        <div id="divMainBodyContent">
                            <div class="cls"></div>
                        </div>
                        <div id="divMainBodyContent">
                            <div id="divMainBodyContentTitle"></div>
                            <div>类别名称:　
                                <input name="<?php echo P_TYPE_NAME ?>" type="text" class="txInput" id="name" value="<?php echo $this->modifyName ?>" >
                        </div>
                        <div class="cls"></div>
                    </div>
                    <div id="divMainBodyContent">
                        <div id="divMainBodyContentTitle"></div>
                        <div>
                            <input name="ok" type="submit" value="  o  k  " class="txInput">
                            <input name="reset" type="reset" value="reset" class="txInput">
                        </div>
                    </div>
                </div>
                <div class="cls"></div>
            </div>
        </form>
        <script language="javascript">
            function countTotalElement(cid, node) {
                if(cid == 0) {
                    document.getElementById('name').value = '';
                    document.getElementById('enname').value = '';
                    document.form1.cid.value='';
                }
                if(node) {
                    var total = 0;
                    if(node.nodeType == 1) {
                        if((node.tagName == 'INPUT' || node.tagName == 'TEXTAREA') && node.id != '') {
                            total++;
                            //node.setAttribute("value","");
                        }
                    }
                    var childrens = node.childNodes;
                    for(var i=0;i<childrens.length;i++) {
                        if(childrens[i].disabled == true) {childrens[i].disabled = false;}
                        total += countTotalElement(cid, childrens[i]);
                    }
                }
            }
            function newClasses() {
                document.getElementById('add_cid').style.display='';
                countTotalElement(0, document.getElementById('classesinfo'));
            }
        </script>
    </body></html>